package com.shopping.www.mapper;


import com.shopping.www.model.Brand;
import com.shopping.www.model.ImportBrand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BusinessMapper {
    //查找指定商家的货架商品id[]
    @Select("select id from busniess_msg where shelveNum>0 and user_id=#{business_id}")
    int[] selectIds(int business_id);
    //查找指定商家的货架商品信息
    List<Brand> selectShelveBrands(@Param("shelveIds") int[] shelveIds);
    //查询货架商品的数量[]
    int[] selectShelveNums(@Param("shelveIds") int[] shelveIds);
    //查询某个商品仓库数量
    @Select("select wareNum from busniess_msg where id=#{brand_id} and user_id=#{business_id}")
    int selectWareNum(@Param("brand_id") int brand_id,@Param("business_id") int business_id);
    //查询某个商品货架数量
    @Select("select shelveNum from busniess_msg where id=#{brand_id} and user_id=#{business_id}")
    int selectBusinessNum(@Param("brand_id") int brand_id,@Param("business_id") int business_id);
    //下架商品
    void leaveFromShelve(@Param("business_id") int business_id,@Param("brand_id") int brand_id,@Param("shelveNum") int shelveNum,@Param("wareNum") int wareNum);
    //查找指定商家的仓库商品id
    @Select("select brand_id from busniess_msg where wareNum>0 and user_id=#{business_id}")
    int[] selectWareIds(int business_id);
    //查找指定商家的仓库商品信息
    List<Brand> selectWareBrands(@Param("wareIds") int[] wareIds);
    //查询仓库商品的数量[]
    int[] selectWareNums(@Param("wareIds") int[] wareIds,@Param("business_id")int business_id);
    //上架商品
    void PutOnShelve(@Param("brand_id")int brand_id,@Param("num") int num,@Param("wareNum") int wareNum,@Param("business_id") int business_id);
    //查询busniess_msg表的id
    @Select("select id from busniess_msg where brand_id=#{brand_id} and user_id=#{business_id}")
    int selectBusiness_msgId(@Param("brand_id") int brand_id,@Param("business_id")int business_id);
    //修改上架商品价格
    void updateBrandPrice(@Param("brand_id") int brand_id,@Param("price") int price,@Param("description") String description,@Param("belong") String belong);
    //查询某个商家所有商品id
    int[] selectBrandIdsByBusinessId(int business_id);
    //根据brand表的id查询商品名
    @Select("select brandName from brand where id=#{id}")
    String selectBrandNameByBrandId(int id);
    //购入仓库商品添加brand表
    void importBrand1(@Param("businessName") String businessName,@Param("importBrand") ImportBrand importBrand);
    //购入仓库商品添加busniess_msg表
    void importBrand2(@Param("business_id") int business_id,@Param("maxId") int maxId,@Param("importBrand") ImportBrand importBrand);
    //查询brand表新添加的数据的id
    @Select("select max(id) from brand")
    int selectMaxId();
    //更新商品的申请封禁
    void applyLiftBan(@Param("brand_id") int brand_id,@Param("liftBanApply") String liftBanApply);
    //查询指定商家的所有属于他的商品id
    @Select("select brand_id from busniess_msg where user_id=#{business_id}")
    int[] selectBrandIds(int business_id);
    //查询配送状态根据商品id
    int[] selectBrandIdsByDeliveryStatus(@Param("brand_id") int[] brand_ids);
    //根据brand_id查询对应的brand
    List<Brand> selectBrandByBrandIds(@Param("brand_id") int[] brand_ids);
    //根据brand_id查询cartNum即配送商品数量
    int[] selectDeliveryNum(@Param("brand_id") int[] brand_id);
    //根据user_msg数据的id查询其brand_id
    int[] selectBrandIdsByDeliveryIds(@Param("ids")int[] deliveryIds);
    //商家呼叫骑手后执行的
    void callDelivery(int deliveryId);
    //根据id查询brand对象
    @Select("select * from brand where id=#{id}")
    Brand addBrandList(int id);
    //为检验能否移除商品做查询货架数量
    int[] selectShelveNumsForCheck(@Param("selectedIds")int[] selectedIds,@Param("business_id")int business_id);
    //删除business_msg的数据
    void deleteWare(@Param("selectedIds")int[] selectedIds,@Param("business_id")int business_id);
}
